<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>档案管理 - 注册</title>
<!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
<script src="libs/jquery.backstretch.min.js"></script>
<script src="libs/identity.js"></script>
<script src="libs/js.cookie-2.1.0.min.js"></script>
<script src="libs/dateFormat.js"></script>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="page-header">
				<h2>
					<strong>档案管理</strong>
				</h2>
			</div>
			<div class="pull-right" className="input-group">
				<input className="form-control" type="text" id="a"
					placeholder="档案号或身份证号" />
				<!--搜索框-->
				<span className="input-group-btn">
					<button className="btn btn-default" onclick={this.submit}
						type="button" id="cha">
						<i className="fa fa-search">搜索</i>
					</button>
				</span>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">

			<div class="col-md-12">
				<ul class="nav nav-pills">
					<li><a href="index.html">首页</a></li>
					<li class="active"><a href="in.html">档案录入</a></li>
					<li><a href="query.html"> 查询</a></li>
					<li><a href="tongji.html"> 统计</a></li>
					<li><a href="more.html"> 档案上传</a></li>
					<li><a href="#">用户：<span id="text3"></span></a></li>
					<li><a id="exit"> 退出</a></li>

				</ul>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<hr />
			</div>
		</div>
	</div>
	<div class="container"></div>
	<div class="container">
		<div class="row">
			<div class="col-md-6 col-md-offset-2">
				<div class="form-group">
					<label for="archive_id">档案号</label> <input type="text"
						class="form-control" id="archive_id" />
				</div>
				<div class="form-group">
					<label for="identity">身份证号</label> <input type="text"
						class="form-control" id="identity" />
					<button id="ident" class="btn btn-primary">检测</button>
				</div>
				<div class="form-group">
					<label for="name">姓名</label> <input type="text"
						class="form-control" id="name" />
				</div>
				<div class="form-group">
					<label for="gender">性别</label> <input type="text"
						class="form-control" id="gender" />
				</div>
				<div class="form-group">
					<label for="birthday">出生日期</label> <input type="date"
						class="form-control" id="birthday" />
				</div>
				<div class="form-group">
					<label for="date_retire1">预退休日期</label> <input type="date"
						class="form-control" id="date_retire1" />
				</div>
				<div class="form-group">
					<label for="date_retire2">实际退休日期</label> <input type="date"
						class="form-control" id="date_retire2" />
				</div>
				<div class="form-group">
					<label for="sp">特殊工种</label> <input type="text"
						class="form-control" id="sp" />
				</div>
				<div class="form-group">
					<label for="fc">女管理岗位</label> <input type="text"
						class="form-control" id="fc" />
				</div>
				<div class="form-group">
					<label for="title">职称</label> <input type="text"
						class="form-control" id="title" />
				</div>

				<div class="form-group">
					<label for="seniority">工龄</label> <input type="text"
						class="form-control" id="seniority" />
				</div>

				<button id="register" class="btn btn-primary btn-block">录入</button>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function() {

			$('#ident').click(function() {
				// console.log(getIdentityInfo($('#identity').val()));
				var identity = getIdentityInfo($('#identity').val());
				if (!identity) {
					return;
				}
				$('#gender').val(identity.gender);
				$('#birthday').val(identity.birthday);
				var dd = new Date(identity.birthday);
				dd.setYear(dd.getFullYear() + 60);
				console.log(dd);
				$('#date_retire1').val(dd.format('yyyy-MM-dd'));
			});
			$('#exit').click(function() {
				$.post('exit.action', {

				}, function(res, status) {
					if ('OK' == res) {
						alert('退出成功');
						window.location.href = 'login.html';
					} else if ('ERR' == res) {
						alert('账号或密码错误');

					}

				});
			});
			$('#register').click(function() {
				if ($('#password').val() !== $('#password2').val()) {
					alter('密码不一致');
					return;
				}
				$.post('add.action', {
					archive_id : $('#archive_id').val(),
					identity : $('#identity').val(),
					name : $('#name').val(),
					gender : $('#gender').val(),
					birthday : $('#birthday').val(),
					date_retire1 : $('#date_retire1').val(),
					date_retire2 : $('#date_retire2').val(),
					sp : $('#sp').val(),
					fc : $('#fc').val(),
					title : $('#title').val(),
					seniority : $('#seniority').val()
				}, function(res, status) {
					if ('OK' == res) {
						alert('注册成功');
						window.location.href = 'index.html';
					} else if ('ERROR_ACCOUNT_OR_PASSWORD' == res) {
						alert('账号或密码错误');
					} else if ('ERR' == res) {
						alert('档案重复或该身份证已有档案');
					}
				});
			});
			$.getJSON('user.action', function(res) {
				//console.log(res);  
				$('#text3').text(res.nickname);
			});
			$('#cha').click(function() {
				$.post('chaxun2.action', {
					a : $('#a').val()
				}, function(res, status) {
					if ('ERR1' == res) {
						alert('未查到档案');
					} else if ('ERR' == res) {
						alert('未定位到准确档案');
					} else {
						window.location.href = 'more.html?id=' + res;
					}
					;
				});
			});
		});
	</script>
	<script type="text/javascript">
		$(function() {
			$.backstretch("456.jpg");
		});
	</script>
	<script type="text/javascript">
		if (!Cookies.get("user")) {
			window.location.href = 'login.html';
		}
	</script>
</body>
</html>
